package com.dream.vo.base;

import java.util.Map;

import com.dream.utils.exception.BusinessException;
import com.google.common.collect.Maps;
/**
 * user account status 
 * (0:输入有误,1:错误,2:异常,3:成功)
 * @copyright evan
 * @author evan
 * @date 2013-8-25
 * 
 */
public enum ResultType {
	INPUT(0),
	ERROR(1),
	EXCEPTION(2),
	SUCCESS(3);
	private final int value;
	private static final Map<Integer,ResultType> map;
	static{
		map = Maps.newHashMap();
		map.put(INPUT.toInteger(), INPUT);
		map.put(ERROR.toInteger(), ERROR);
		map.put(EXCEPTION.toInteger(), EXCEPTION);
		map.put(SUCCESS.toInteger(), SUCCESS);
	}
	private ResultType(int val){
		value = val;
	}

	public int toInteger(){
		return value;
	}
	
	public static ResultType instance(int val){
		
		if(map.containsKey(val)){
			return map.get(val);
		}else{
			throw new BusinessException("Unsupport to instance the val= " + val);
		}
		
	}
}
